
#ifndef GAMEENGINE_H
#define GAMEENGINE_H

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <vector>
using namespace std;

const int X=30;
const int Y=30;
const int WALL=3;
const int GOTO=9;
class CGameState;

class CGameEngine
{
public:
    SDL_Surface* player;
    SDL_Surface* bg;
    SDL_Surface* tile;
    SDL_Rect dstrect;
    int map[256][256];
    int ppx, ppy;
    int mx, my, px, py;
    int msx, msy;
    SDL_Rect maprend[256][256];

    void Init(const char* title, int width=300, int height=270,
              int bpp=0, bool fullscreen=false);
    void Cleanup();
    void RegulateFPS();
    void UpdateScreen();
    void ChangeState(CGameState* state);
    void PushState(CGameState* state);
    void PopState();

    void HandleEvents();
    void Update();
    void Draw();

    bool Running()
    {
        return m_running;
    }
    void Quit()
    {
        m_running = false;
    }

    SDL_Surface* screen;

private:
    // the stack of states
    vector<CGameState*> states;
    Uint32 curTicks;
    bool m_running;
    bool m_fullscreen;
};

#endif
